A pool with pre-created threads, allowing to queue work asynchronously.
More...
A pool with pre-created threads, allowing to queue work asynchronously.
◆ ThreadPool()
| nkTasks::ThreadPool::ThreadPool |
( |
unsigned int |
threadCount = 0 | ) |
|
|
noexcept |
Constructor.
- Parameters
-
| threadCount | The number of threads the pool should prepare. |
◆ ~ThreadPool()
| nkTasks::ThreadPool::~ThreadPool |
( |
| ) |
|
◆ getThreadCount()
| unsigned int nkTasks::ThreadPool::getThreadCount |
( |
| ) |
const |
- Returns
- The number of threads contained in the pool.
◆ getThread()
| Thread* nkTasks::ThreadPool::getThread |
( |
unsigned int |
index | ) |
const |
- Parameters
-
| index | The index of the thread to retrieve, within the pool. |
- Returns
- The thread attached to the index requested if available, nullptr otherwise.
◆ addTask()
Add a task to be pooled.
- Parameters
-
| task | The task to be processed. |
◆ cancelPendingTasks()
| void nkTasks::ThreadPool::cancelPendingTasks |
( |
| ) |
|
Cancels all the tasks queued, waiting to be picked by a thread from the pool.
◆ flush()
| void nkTasks::ThreadPool::flush |
( |
| ) |
|
Flushes all pending work and only returns once the pool has processed everything.
◆ resizeForThreadCount()
| void nkTasks::ThreadPool::resizeForThreadCount |
( |
unsigned int |
threadCount | ) |
|
Resizes the pool with a different amount of threads.
- Parameters
-
| threadCount | The number of threads the pool should feature. |
The documentation for this class was generated from the following file: